package com.artisan.booteventbus.listeners;

import com.artisan.booteventbus.domain.MessageSentEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MessageSentEventListener {

    @Async
    @EventListener
    public void handleMessageSentEvent(MessageSentEvent event) {
        // 模拟处理事件
        System.out.println(Thread.currentThread().getName() + " - Received MessageSentEvent: " + event.getOriginalEvent().getMessage());
        log.info("Sending email: {}", event.getOriginalEvent().getMessage());

    }
}
